Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-pty

Package Overview
Dependencies
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pty

Fork pseudoterminals in Node.JS

  • 0.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
112K
decreased by-22.18%
Maintainers
3
Weekly downloads
 
Created

What is node-pty?

The node-pty package is a Node.js library that provides bindings to pseudo terminals (PTYs). It allows you to spawn and interact with terminal processes programmatically, making it useful for building terminal emulators, remote shells, and other command-line interface (CLI) tools.

What are node-pty's main functionalities?

Spawning a Terminal Process

This feature allows you to spawn a terminal process. The code sample demonstrates how to spawn a shell process and listen for data events to capture the terminal output.

const pty = require('node-pty');
const shell = process.env[process.platform === 'win32' ? 'COMSPEC' : 'SHELL'];
const ptyProcess = pty.spawn(shell, [], {
  name: 'xterm-color',
  cols: 80,
  rows: 30,
  cwd: process.cwd(),
  env: process.env
});
ptyProcess.on('data', function(data) {
  console.log(data);
});

Resizing the Terminal

This feature allows you to resize the terminal window. The code sample shows how to resize the terminal to 100 columns and 40 rows.

ptyProcess.resize(100, 40);

Writing to the Terminal

This feature allows you to send input to the terminal process. The code sample demonstrates how to send the 'ls' command to the terminal.

ptyProcess.write('ls\r');

Other packages similar to node-pty

Keywords

FAQs

Package last updated on 23 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc